var dnsdetector = require('../../../monitor/detector/dns');
var _ = require('underscore');



describe('dns 解析', function () {
  before(function () {
    // console.log('Pre something');
  });
  describe('baidu.com 使用默认dns（114.114.114.114）解析', function () {
    it('耗时应该小于1000ms', function (done) {
      dnsdetector.detect({
        name: 'baidu.com'
      },function(data){
        expect(data.times.end - data.times.start).not.toBeGreaterThan(1000);
        done();
      });
    });

    
    it('180.149.132.47 应该返回ip列表里', function (done) {
      dnsdetector.detect({
        name: 'baidu.com'
      },function(data){

        expect(data.result.ip).toContain('180.149.132.47');
        done();
      });
    });    
  });


  describe('douban.com 使用8.8.8.8解析测试', function(){
    it('耗时应该小于1000ms', function (done){
      dnsdetector.detect({
        name: 'douban.com',
        ns: '8.8.8.8'
      },function (data){
        expect(data.times.end - data.times.start).not.toBeGreaterThan(1000);
        done();
      });      
    });

    it('返回结果应该包含 211.147.4.31', function (done){
      dnsdetector.detect({
        name: 'douban.com',
        ns: '8.8.8.8'
      },function (data){
        expect(data.result.ip).toContain('211.147.4.31');
        done();
      });      
    });

  }); 

  after(function () {
    // console.log('Post something');
  });
});










